﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace YushengMall.Backend.Api.Migrations
{
    public partial class initdatabase : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "MenuRes",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    tagTypeId = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    value = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    userId = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    IsActived = table.Column<bool>(type: "bit", nullable: false),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MenuRes", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "sheet",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    sheetname = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    IsActived = table.Column<bool>(type: "bit", nullable: false),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_sheet", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "SystemMenu",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    RoleID = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    key = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    name = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    mast = table.Column<bool>(type: "bit", nullable: false),
                    placeholder = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    tagTypeId = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    invalue = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    outvalue = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    page = table.Column<int>(type: "int", nullable: false),
                    IsActived = table.Column<bool>(type: "bit", nullable: false),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SystemMenu", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "tagType",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    TagTypeName = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    IsActived = table.Column<bool>(type: "bit", nullable: false),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_tagType", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "User",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    UserName = table.Column<string>(type: "nvarchar(20)", nullable: true),
                    NickName = table.Column<string>(type: "nvarchar(20)", nullable: true),
                    PassWord = table.Column<string>(type: "varchar(20)", nullable: true),
                    VChartNumber = table.Column<string>(type: "varchar(50)", nullable: true),
                    QQNumber = table.Column<string>(type: "varchar(20)", nullable: true),
                    PhoneNumber = table.Column<string>(type: "varchar(11)", nullable: true),
                    Email = table.Column<string>(type: "varchar(100)", nullable: true),
                    CardNumber = table.Column<string>(type: "varchar(100)", nullable: true),
                    RealName = table.Column<string>(type: "varchar(100)", nullable: true),
                    Sex = table.Column<string>(type: "char(1)", nullable: false),
                    RoleID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    IsActived = table.Column<bool>(type: "bit", nullable: false),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_User", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Role",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    RoleName = table.Column<string>(type: "varchar(20)", nullable: true),
                    sheetID = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    IsActived = table.Column<bool>(type: "bit", nullable: false),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Role", x => x.ID);
                    table.ForeignKey(
                        name: "FK_Role_sheet_sheetID",
                        column: x => x.sheetID,
                        principalTable: "sheet",
                        principalColumn: "ID");
                });

            migrationBuilder.CreateTable(
                name: "menuTagType",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    TagTypeID = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    SystemMenuID = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    MenuResID = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    IsActived = table.Column<bool>(type: "bit", nullable: false),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_menuTagType", x => x.ID);
                    table.ForeignKey(
                        name: "FK_menuTagType_MenuRes_MenuResID",
                        column: x => x.MenuResID,
                        principalTable: "MenuRes",
                        principalColumn: "ID");
                    table.ForeignKey(
                        name: "FK_menuTagType_SystemMenu_SystemMenuID",
                        column: x => x.SystemMenuID,
                        principalTable: "SystemMenu",
                        principalColumn: "ID");
                    table.ForeignKey(
                        name: "FK_menuTagType_tagType_TagTypeID",
                        column: x => x.TagTypeID,
                        principalTable: "tagType",
                        principalColumn: "ID");
                });

            migrationBuilder.CreateTable(
                name: "UserRole",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    RoleID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    UserID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    IsActived = table.Column<bool>(type: "bit", nullable: false),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserRole", x => x.ID);
                    table.ForeignKey(
                        name: "FK_UserRole_Role_RoleID",
                        column: x => x.RoleID,
                        principalTable: "Role",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_UserRole_User_UserID",
                        column: x => x.UserID,
                        principalTable: "User",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.InsertData(
                table: "Role",
                columns: new[] { "ID", "CreateTime", "IsActived", "IsDeleted", "RoleName", "UpdateTime", "sheetID" },
                values: new object[] { new Guid("8fdd4d6e-9f96-40c9-a71c-36ab55f3e2b6"), new DateTime(2022, 4, 6, 15, 2, 30, 698, DateTimeKind.Local).AddTicks(8075), true, false, "用户", new DateTime(2022, 4, 6, 15, 2, 30, 698, DateTimeKind.Local).AddTicks(8076), null });

            migrationBuilder.InsertData(
                table: "Role",
                columns: new[] { "ID", "CreateTime", "IsActived", "IsDeleted", "RoleName", "UpdateTime", "sheetID" },
                values: new object[] { new Guid("b1188013-ffa3-4bfe-bdd5-0030278c71da"), new DateTime(2022, 4, 6, 15, 2, 30, 698, DateTimeKind.Local).AddTicks(8065), true, false, "管理员", new DateTime(2022, 4, 6, 15, 2, 30, 698, DateTimeKind.Local).AddTicks(8073), null });

            migrationBuilder.InsertData(
                table: "User",
                columns: new[] { "ID", "CardNumber", "CreateTime", "Email", "IsActived", "IsDeleted", "NickName", "PassWord", "PhoneNumber", "QQNumber", "RealName", "RoleID", "Sex", "UpdateTime", "UserName", "VChartNumber" },
                values: new object[] { new Guid("e231bf1e-4737-4512-bdad-912700658219"), null, new DateTime(2022, 4, 6, 15, 2, 30, 698, DateTimeKind.Local).AddTicks(8160), null, true, false, "系统管理员", ".jxy123,", null, null, null, new Guid("b1188013-ffa3-4bfe-bdd5-0030278c71da"), " ", new DateTime(2022, 4, 6, 15, 2, 30, 698, DateTimeKind.Local).AddTicks(8161), "amdin", null });

            migrationBuilder.InsertData(
                table: "UserRole",
                columns: new[] { "ID", "CreateTime", "IsActived", "IsDeleted", "RoleID", "UpdateTime", "UserID" },
                values: new object[] { new Guid("eada6529-d1b1-4060-ac54-8690e0c4f278"), new DateTime(2022, 4, 6, 15, 2, 30, 698, DateTimeKind.Local).AddTicks(8184), true, false, new Guid("b1188013-ffa3-4bfe-bdd5-0030278c71da"), new DateTime(2022, 4, 6, 15, 2, 30, 698, DateTimeKind.Local).AddTicks(8184), new Guid("e231bf1e-4737-4512-bdad-912700658219") });

            migrationBuilder.CreateIndex(
                name: "IX_menuTagType_MenuResID",
                table: "menuTagType",
                column: "MenuResID");

            migrationBuilder.CreateIndex(
                name: "IX_menuTagType_SystemMenuID",
                table: "menuTagType",
                column: "SystemMenuID");

            migrationBuilder.CreateIndex(
                name: "IX_menuTagType_TagTypeID",
                table: "menuTagType",
                column: "TagTypeID");

            migrationBuilder.CreateIndex(
                name: "IX_Role_sheetID",
                table: "Role",
                column: "sheetID");

            migrationBuilder.CreateIndex(
                name: "IX_UserRole_RoleID",
                table: "UserRole",
                column: "RoleID");

            migrationBuilder.CreateIndex(
                name: "IX_UserRole_UserID",
                table: "UserRole",
                column: "UserID");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "menuTagType");

            migrationBuilder.DropTable(
                name: "UserRole");

            migrationBuilder.DropTable(
                name: "MenuRes");

            migrationBuilder.DropTable(
                name: "SystemMenu");

            migrationBuilder.DropTable(
                name: "tagType");

            migrationBuilder.DropTable(
                name: "Role");

            migrationBuilder.DropTable(
                name: "User");

            migrationBuilder.DropTable(
                name: "sheet");
        }
    }
}
